<%@ page import="com.edu.service.BookService" %>
<%@ page import="com.edu.service.impl.BookServiceImpl" %>
<%@ page import="com.edu.entity.Book" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.edu.service.BookService" %>
<%@ page import="com.edu.service.impl.BookServiceImpl" %>
<%--
  Created by IntelliJ IDEA.
  User: heci
  Date: 2024/9/14
  Time: 8:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>图书管理页面</title>
</head>
<body>
    <%
        String username = (String)session.getAttribute("name");
        String userPass = (String)session.getAttribute("pass");
        if(username == null){
            response.sendRedirect("login.jsp");
        }
    %>
    <table>
        <tr>
            <td>id</td>
            <td>书名</td>
            <td>类型</td>
            <td>作者</td>
        </tr>
            <%
			BookService bookService=new BookServiceImpl();
			Object obj=request.getAttribute("list");
			List<Book> list=new ArrayList<Book>();
			if(obj!=null){
				list=(List<Book>)obj;
			}else {
				list=bookService.queryAll();
			}
			for(int i=0;i<list.size();i++){
				Book book=list.get(i);
			%>
        <tr>
            <td><%=book.getId()%></td>
            <td><%=book.getBookName()%></td>
            <td><%=book.getBookType()%></td>
            <td><%=book.getWrites()%></td>
        </tr>
        <%
            }
        %>
    </table>
    </form>
    </table>
</body>
</html>